package mao.thinkinjava.io;

import java.nio.charset.Charset;
import java.util.Iterator;
import java.util.Set;
import java.util.SortedMap;

public class AvailableCharSets {
    public static void main(String[] args) {
        SortedMap<String, Charset> map = Charset.availableCharsets();
        Set<String> keys = map.keySet();
        Iterator<String> iterator = keys.iterator();
        while (iterator.hasNext()){
            String next = iterator.next();
            if (!next.matches("UTF.*")) continue;
            System.out.println(next);
            Charset charset = map.get(next);
            Set<String> aliases = charset.aliases();
            Iterator<String> it = aliases.iterator();
            if (it.hasNext()) System.out.print("   :");
            while (it.hasNext()){
                System.out.println(it.next());
            }
        }
    }
}
